import React, { useState } from 'react'
import axios from 'axios'
import md5 from 'md5'
import { Button } from 'antd'
function Index() {
    const [data,setData] = useState('')
    const salt = new Date().getTime()
    const sign = md5(
        "0feffc81d49573bc" + "你好" + salt + "EbY4OnjALRRUNdNZfEgsteFu2CnWRE1m"
    )
    const fy = () => {
        axios.get('youdao/api', {
            params: {
                q: '你好',
                from: 'auto',
                to: 'en',
                appKey: '0feffc81d49573bc',
                salt,
                sign
            }
        }).then((res) => {
            console.log(res.data.translation[0])
            setData(res.data.translation[0])
        })
    }
    return (
        <div>
            <Button onClick={() => fy()}>翻译</Button>
             {data}
        </div>
    )
}

export default Index
